package cn.edu.hpu.dao;


import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;


import cn.edu.hpu.pojo.Contacts;
@Repository
public class ContactsDao extends BaseDao<Contacts, String> {
	@SuppressWarnings("unchecked")
	public List<Contacts> findByNameOrCompanyname(String name){
		//String hql = "from Contacts where name like ? or companyname like ?";
		Criteria c = getSession().createCriteria(Contacts.class);
		c.add(Restrictions.or(Restrictions.eq("name", "%"+name+"%"), Restrictions.eq("companyname", "%"+name+"%")));
		return c.list();
	}
}
